package com.yang.SpringTest.annotation.lookupLearn;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

/**
 * <p>【spring】@Lookup注解学习</p>
 * 测试 SingletonBean 是否每次都能获取到新的 PrototypeBean 实例
 *
 * @author By: chengxuyuanshitang <br>
 * @Package: com.yang.SpringTest.annotation.lookupLearn <br>
 * @CreateTime: 2024-11-20 14:02 <br>
 */
@Slf4j
public class LookupTest {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(LookupAppConfig.class);
        log.info("**************** IOC容器启动完成....");
        String[] definitionNames = context.getBeanDefinitionNames();
        Arrays.stream(definitionNames).forEach((definitionName) -> System.out.println("=====" + definitionName));

        DemoSingletonBean demoSingletonBean = context.getBean(DemoSingletonBean.class);

        demoSingletonBean.useDemoPrototypeBean();
        demoSingletonBean.useDemoPrototypeBean();


        context.close();
    }
}